import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import "./index.css"
import { isLogined } from '../pages/auth'
import axios from 'axios'
import { Tabs } from "antd";
// import get from "../api/api";

function Heand(props) {
    //    const username= useParams();
    const username = sessionStorage.getItem('username')
    const navigate = useNavigate()
    // 跳转路径
    const gologin = () => {
        navigate('/login')
    }
    const goclassdoor = ()=>{
        navigate('/add_newdoor_class_door')
    }
    const gohome = () => {
        navigate('/')
    }
    const gogwc = () => {
        navigate('/mygwc')
    }
    const gozhuce = () => {
        navigate('/zhuce')
    }
    const dianpu = () => {
        navigate('/dianpu')
    }
    const add_products = () => {
        navigate('/add_products')
    }
    const add_push_door = ()=>{
        navigate('/add_products_push_door')
    }
    const zc = () => {
        navigate('/zc')
    }
    const good =()=>{
        navigate('/add_newdoor')
    }
    const cailiao =()=>{
        navigate('/add_newdoor_cailiao')
    }
    const home =()=>{
        navigate('/add_newdoor_home')
    }
    const jj =()=>{
        navigate('/jj')
    }
    const pctext = ()=>{
        navigate('/add_newdoor_pctext')
    }
    const pcphone = () =>{
        navigate('/add_newdoor_pcphone')
    }
    const pcclass = ()=>{
        navigate('/add_newdoor_pcclass')
    }
    const lunbo = ()=>{
        navigate('/add_newdoor_lunbo')
    }
    const jianjieimage = ()=>{
        navigate('/add_products_push_jianjieimage')
    }
    const myimage = ()=>{
        navigate('/add_products_push_myimage')
    }
    const tuichu = () => {
        sessionStorage.removeItem('username');
        sessionStorage.removeItem('password');
        window.location.reload();
        navigate('/')
        // username='none'
        // console.log("123123")
        // 测试
    }
    const cs = () => {
        navigate('/cs')
    }
    // const name=props.username


    const [open, setOpen] = useState('none')

    // console.log(username)
    useEffect(() => {

    })


    // }
    // console.log(NoN)
    var non = ''
    // console.log(name)
    var log = '亲，请先登录'
    if (isLogined() === true) {
        log = '亲，欢迎' + sessionStorage.getItem('username')
        non = ''
        axios.get(`https://r5ctn9z9.lc-cn-n1-shared.com/1.1/classes/people`
            , {
                params: { where: { username: username } }, headers: {
                    " X-LC-Id": "r5CTN9z96pCW8mI8fx9YxOmw-gzGzoHsz",
                    "X-LC-Key": "8gSsl4Sz0ILMiQeMNMA8xQqg",
                    "Content-Type": ""
                }
            }).then((res) => {
                console.log(res.data.results[0].gly)
                // opengl=res.data.re
                if (res.data.results[0].gly === 'false') {
                    setOpen('none')
                }
                else {
                    setOpen('')
                }
            })
        //  window.location.reload();
    }
    else {
        log = '亲，请先登录'
        non = 'none'
    }
    var login = ''
    if (username !== null) {
        login = 'none'
    }



    return (
        <div className="dh">
            <div className="toptext"><span>欢迎光临，给您带来更好的购物体验</span></div>
            <div className="first">

                <ul className="daohang">
                <li onClick={gologin}>{log}</li>
                    <li onClick={gohome}>商城首页</li>
                    <li onClick={jj}>简介</li>

                    {/* <li onClick={gologin}>{username}</li> */}
                    {/* <li onClick={gogwc}>我的购物车</li> */}
                    {/* <li onClick={cs}>cs</li> */}
                    
                    <li onClick={add_push_door}>添加商品</li>
                   
                    <li onClick={lunbo}>添加轮播图</li>
                    {/* <li onClick={dianpu}>我的店铺</li> */}
                    <li onClick={pcclass}>添加商品类别</li>
                    <li onClick={pcphone}>修改联系方式</li>
                    <li onClick={good}>第一个添加</li>
                    <li onClick={cailiao}>添加材料</li>
                    <li onClick={home}>添加室内效果</li>
                    <li onClick={pctext}>修改简介文字</li>
                    {/* <li onClick={tuichu} style={{ display: non }}>退出登录</li> */}
                    
                    {/* <li style={{ display: login }} onClick={zc} >前去注册</li> */}
                    {/* <li onClick={add_products}>添加商品</li> */}
                    <li onClick={gozhuce} style={{ display: open }}>管理后台系统</li>
                    <li onClick={jianjieimage}>添加简介背景图</li>
                    <li onClick={myimage}>添加介绍背景图</li>

                </ul>

            </div>

        </div>
    )
}

export default Heand